package com.czxy.service;

import cn.itcast.commons.CommonUtils;
import com.czxy.dao.UserMapper;
import com.czxy.domain.User;
import com.czxy.utils.MyBatisUtils;

public class UserService {



    public  void register(User user){
        UserMapper mapper = MyBatisUtils.getMapper(UserMapper.class);
        user.setUid(CommonUtils.uuid());
        mapper.insert(user);
        MyBatisUtils.commitAndClose();


    }



    //根据用户名获取用户数据
    public User  findUserByUsername (String username){
        UserMapper mapper = MyBatisUtils.getMapper(UserMapper.class);
        User user = mapper.findUserByUsername(username);
        MyBatisUtils.close();
        return user;
    }



    }




